package com.gxuwz.library_consumer.service;

import com.github.pagehelper.PageInfo;
import com.gxuwz.commonmodule.entity.Account;
import com.gxuwz.commonmodule.entity.Admin;
import com.gxuwz.commonmodule.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Component
@FeignClient(value = "admin-provider")
public interface AccountService {

    /**
     * 用户登陆
     * @param username
     * @param password
     * @param role
     * @return
     */
    @GetMapping("/login/{username}/{password}/{role}")
    public Account login(@PathVariable("username") String username, @PathVariable("password") String password, @PathVariable("role")String role );
    /**
     * 用户注册
     * @param username
     * @param password
     * @param role
     * @return
     */
    @GetMapping(value = "/register")
    public int register(@RequestParam(value = "username") String username,
                        @RequestParam(value = "name")String name,
                        @RequestParam(value = "password") String password,
                        @RequestParam(value = "email")String email,
                        @RequestParam(value = "phone")String phone,
                        @RequestParam(value = "address")String address,
                        @RequestParam(value = "balance")String balance,
                        @RequestParam(value = "role") String role);

    /**
     * 添加管理员信息
     * @param admin
     */
    @PostMapping("/add")
    public void insert(@RequestBody Admin admin);

    /**
     * 通过username删除管理员信息
     * @param username
     */
    @DeleteMapping("/delete/{username}")
    public void deleteAdmin (@PathVariable("username")String username);

    /**
     * 更新管理员信息
     * @param admin
     */
    @PutMapping("/update")
    public void updateAdmin(@RequestBody Admin admin);

    /**
     * 通过username 查询管理员信息
     * @param username
     * @return
     */
    @GetMapping("/findById/{username}")
    public Admin findById(@PathVariable("username")String username);

    /**
     * 查询所有管理员信息
     * @param admin
     * @return
     */
    @GetMapping("/list")
    public List<Admin> list(@RequestBody Admin admin);

    /**
     * 修改管理员信息
     * @param username
     * @return
     */
    @GetMapping("/{username}")
    public Admin findInfo(@PathVariable("username") String username);

    /**
     * 分页查询管理员信息
     * @param pageIndex
     * @param pageSize
     * @return
     */
    @GetMapping("/findPage")
    PageInfo findPage(@RequestParam(value = "pageIndex") int pageIndex, @RequestParam(value = "pageSize") int pageSize);
}
